<template>
  <el-table :data="list" style="width: 100%">
    <el-table-column align="center" type="index"></el-table-column>
    <el-table-column
      align="center"
      prop="taskCode"
      label="工单编号"
      width="160"
    >
    </el-table-column>
    <el-table-column
      align="center"
      prop="innerCode"
      label="设备编号"
      width="150"
    >
    </el-table-column>
    <el-table-column align="center" label="工单类型" width="140">
      <template #default="{ row }">
        {{ row.taskType && row.taskType.typeName }}
      </template>
    </el-table-column>
    <el-table-column align="center" label="工单方式" width="120">
      <template #default="{ row }">{{
        row.createType === 1 ? "手动" : "自动"
      }}</template>
    </el-table-column>
    <el-table-column
      align="center"
      prop="taskStatusTypeEntity.statusName"
      label="工单状态"
      width="130"
    >
    </el-table-column>
    <el-table-column
      align="center"
      prop="userName"
      label="运营人员"
      width="150"
    >
    </el-table-column>
    <el-table-column align="center" prop="createTime" label="日期" width="180">
    </el-table-column>
    <el-table-column align="center" label="操作" width="160" prop="taskId">
      <template slot-scope="scope">
        <el-button type="text" size="small" @click="open(scope.row.taskId)"
          >查看详情</el-button
        >
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import { taskInfoApi } from "@/api/task";
export default {
  props: {
    list: {
      type: Array,
      default: () => [],
    },
    dialogVisible: {
      type: Boolean,
      default: true,
    },
    info: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      id: "",
    };
  },
  methods: {
    async open(id) {
      // console.log(id);
      const res = await taskInfoApi(id);
      // console.log(res);
      this.$emit("update:info", res.data);
      this.$emit("update:dialogVisible", true);
    },
  },
  computed: {
    createTypeFn() {
      if (this.info.createType === 1) {
        return "手动";
      } else if (this.info.createType === 0) {
        return "自动";
      }
    },
  },
};
</script>
